# +----------------------------------------------------------------------
# | Pink [ A modern python web framework ]
# +----------------------------------------------------------------------
# | Copyright (c) 2023 http:#unnnnn.com All rights reserved.
# +----------------------------------------------------------------------
# | Author: chenjianhua <unnnnn@foxmail.com>
# +----------------------------------------------------------------------


""" A ScheduleRunCommand Command """
#from cleo import Command
from cleo.commands.command import Command


class ScheduleRunCommand(Command):
    name = 'schedule:run'
    description = 'Run the scheduled tasks'
    """
    Run the scheduled tasks
    schedule:run
        {--t|task=? : Name of task you want to run (else all scheduled tasks will be ran)}
        {--f|force : Force running task immediately}
    """

    def __init__(self, application):
        super().__init__()
        self.app = application

    def handle(self):
        return self.app.make("scheduler").run(
            run_name=self.option("task"), force=self.option("force")
        )
